package com.loveyukari.utils;

import java.io.InputStream;
import java.net.URL;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
*yangshaohua
*2017年8月10日下午3:32:35
**/
public class ImageUtils {
	
	private static Logger LOG = LoggerFactory.getLogger(ImageUtils.class);

	public static String getImageBase64(String url){
		try {
			InputStream input = new URL(url).openStream();
			byte[] bs = IOUtils.toByteArray(input);
			String img = new String(Base64.encodeBase64(bs));
			return img;
		} catch (Exception e) {
			LOG.error(e.getMessage(),e);
			return "";
		}
	}
	
}
